SPB Git forge

spb/cancerindex

Public
37commits 1branches 0releases
2.9 MBsize
maindefault branch
10 days agolast push
TypeScript 97.2% SQL 1.5% CSS 0.6% JavaScript 0.5%
1.3 KB · 27 lines tsx
Raw Blame History
1import { ogImage, OG_SIZE, OG_CONTENT_TYPE } from '@/lib/og';2import { getDrugBySlug } from '@/lib/queries/drugs';3import { fmtInt, humanize } from '@/lib/format';45export const alt = 'CancerIndex drug page';6export const size = OG_SIZE;7export const contentType = OG_CONTENT_TYPE;8export const revalidate = 3600;910export default async function Image({ params }: { params: Promise<{ slug: string }> }) {11  const { slug } = await params;12  const d = await getDrugBySlug(slug);13  if (!d) return ogImage({ kicker: 'Drug', title: 'Drug not found', subtitle: slug });14  const facts = [15    d.approval_count ? { label: 'approval records', value: fmtInt(d.approval_count) } : null,16    d.trial_count ? { label: 'registered trials', value: fmtInt(d.trial_count) } : null,17    d.evidence_count ? { label: 'curated evidence items', value: fmtInt(d.evidence_count) } : null,18  ].filter((f): f is { label: string; value: string } => !!f);19  return ogImage({20    kicker: `Drug${d.kind ? ` · ${humanize(d.kind)}` : ''}${d.chembl_id ? ` · ${d.chembl_id}` : ''}`,21    title: d.name,22    subtitle: d.mechanism ?? d.description ?? 'Jurisdiction-aware approvals, curated evidence, development pipeline and clinical trials.',23    facts,24    sourcesNote: 'openFDA · Health Canada · EMA · CIViC · ClinicalTrials.gov',25  });26}27